home *** CD-ROM | disk | FTP | other *** search
/ IRIX Patches 1995 September / SGI IRIX Patches 1995 Sep.iso / 5.3_patches / patchSG0000620 / patchSG0000620.idb / usr / share / catman / a_man / cat1 / ipfilterd.z / ipfilterd
Text File  |  1995-09-07  |  13KB  |  322 lines

  1.  
  2.  
  3.  
  4. IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))                                                    IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      ipfilterd - IP packet filtering daemon
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ////uuuussssrrrr////eeeettttcccc////iiiippppffffiiiilllltttteeeerrrrdddd [ ----dddd ]
  13.  
  14. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  15.      _I_p_f_i_l_t_e_r_d is a networking daemon that screens all inbound packets that
  16.      use the Internet Protocol (IP). Packets are filtered based on their
  17.      source or destination IP address, the network interface they arrived on,
  18.      their IP protocol number, their source or destination TCP/UDP port
  19.      number, or any combination of the above. Supported IP protocols include
  20.      TCP, UDP, ICMP and IGMP.
  21.  
  22.      _I_p_f_i_l_t_e_r_d is started at system initialization from /_e_t_c/_i_n_i_t._d/_n_e_t_w_o_r_k if
  23.      the configuration flag _i_p_f_i_l_t_e_r_d is set ``on'' with _c_h_k_c_o_n_f_i_g(1M).  When
  24.      _i_p_f_i_l_t_e_r_d is started, it reads its configuration information from the
  25.      file /_e_t_c/_i_p_f_i_l_t_e_r_d._c_o_n_f and compiles the packet filters specified there,
  26.      storing them in an array in the order in which they were specified.
  27.      Inbound IP code passes packet information to the daemon, requesting
  28.      verdicts based on the filter database. An inbound packet is compared with
  29.      each filter in the array until a match is found, then the verdict
  30.      associated with that filter is returned to IP, which will process the
  31.      packet unless it has been dropped by the filtering code. If no match is
  32.      found, the packet is dropped by default.
  33.  
  34.      During filter initialization, _i_p_f_i_l_t_e_r_d reads /_e_t_c/_i_p_f_i_l_t_e_r_d._c_o_n_f one
  35.      line at a time. Lines that begin with "#" are comments and are ignored.
  36.      All other lines begin with a keyword, followed by either a macro or a
  37.      filter. Macros and filters use _n_e_t_s_n_o_o_p(1M) filter syntax; however, the
  38.      optional specification of a network interface must precede all protocol
  39.      filter information.  All standard _n_e_t_s_n_o_o_p(1M) macros relating to
  40.      _i_p_f_i_l_t_e_r_d'_s supported protocols may be used.
  41.  
  42.      Currently supported keywords include:
  43.         accept   accept all packets matching this filter
  44.         grab     grab all packets matching this filter rather than forwarding them
  45.         reject   silently discard all packets matching this filter
  46.         define   define a new macro
  47.  
  48.      IP addresses may be specified in hexadecimal, in Internet dot format (see
  49.      _i_n_e_t(3N)), or by the fully-qualified hostname or its nickname:
  50.  
  51.         0xC000022C  192.0.2.44   bambi.test.com  bambi
  52.      IP protocols may be referenced either by their assigned IP protocol
  53.      number or by their well-known name (tcp, udp, icmp, igmp), as listed in
  54.      /_e_t_c/_p_r_o_t_o_c_o_l_s.  Ports may likewise be referenced directly by number;
  55.      port numbers assigned to specific Internet network or UNIX-specific ser-
  56.      vices may also be referenced by the well-known names found in
  57.      /_e_t_c/_s_e_r_v_i_c_e_s (e.g., ftp, telnet, snmp, sunrpc, login, etc.).
  58.  
  59.  
  60.  
  61.                                                                         PPPPaaaaggggeeee 1111
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))                                                    IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))
  69.  
  70.  
  71.  
  72.      _I_p_f_i_l_t_e_r_d will support up to 100 discrete filters. There is no limit on
  73.      the number of macros that may be defined.
  74.  
  75.      IP maintains a kernel cache of recent _i_p_f_i_l_t_e_r_d filtering verdicts,
  76.      arranged in a most-recently-used linked list.  The size of this cache is
  77.      configurable, as is the search depth into the cache before a filter match
  78.      causes the matched entry to be moved to the head of the cache (MRU reord-
  79.      ering). With the 5.0 release of IRIX, cache entries will be aged and
  80.      deleted when idle for a configurable interval (default 60 seconds).  Use
  81.      of the cache decreases the number of times that IP must poll the daemon,
  82.      reducing system overhead associated with context switching out of the
  83.      kernel.
  84.  
  85.      While a larger cache minimizes context switches, its size adds a longer
  86.      search path overhead to the IP kernel code before a decision to consult
  87.      the daemon may be made. The optimum cache size will vary with system
  88.      usage - e.g., an external gateway will have more filtering responsibility
  89.      and will see many more IP-address/protocol/port combinations than a
  90.      workstation on a LAN; hence it will require a larger cache.
  91.  
  92.      The number of verdicts cached in the kernel is defined by the constant
  93.      _N_U_M_I_P_K_F_L_T in the IP filtering configuration file
  94.      /_v_a_r/_s_y_s_g_e_n/_m_a_s_t_e_r._d/_i_p_f_i_l_t_e_r.  To change the size, as the superuser edit
  95.      this file and then use _a_u_t_o_c_o_n_f_i_g(1M) to generate a new kernel and
  96.      reboot.
  97.  
  98.      The effects of kernel cache size can be observed empirically by monitor-
  99.      ing network performance, and also by explicitly observing how often and
  100.      to what effect the daemon is being used. Executing _i_p_f_i_l_t_e_r_d with the ----dddd
  101.      option provides that information. It turns on additional use of
  102.      _s_y_s_l_o_g_d(1M) to log data about each filter that is built, and also about
  103.      each daemon filtering request. This includes: an indication of whether
  104.      the packet matched a filter or was dropped by default; whether the filter
  105.      was one that specified an interface only, or included protocol informa-
  106.      tion; a timestamp; and a running count of the number of times that kind
  107.      of decision happened.
  108.  
  109. FFFFIIIILLLLEEEESSSS
  110.      /_v_a_r/_a_d_m/_S_Y_S_L_O_G is the general _s_y_s_l_o_g_d(1M) data file. It contains all
  111.      events and data logged by _i_p_f_i_l_t_e_r_d.  /_e_t_c/_i_p_f_i_l_t_e_r_d._c_o_n_f contains macro
  112.      and filter definitions.
  113.  
  114.      /_v_a_r/_s_y_s_g_e_n/_m_a_s_t_e_r._d/_i_p_f_i_l_t_e_r is used when generating a kernel to specify
  115.      the size of the kernel cache of recent filtering verdicts, the cache
  116.      search depth that must be exceeded before any MRU reordering of the cache
  117.      is performed, and the treatment of inbound IP packets when the filtering
  118.      daemon has died or been killed.
  119.  
  120.      The constant NUMIPKFLT defines the size of the kernel cache of recent
  121.      filtering verdicts. This should be tuned based on system load.
  122.  
  123.  
  124.  
  125.  
  126.  
  127.                                                                         PPPPaaaaggggeeee 2222
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))                                                    IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))
  135.  
  136.  
  137.  
  138.      The _f_i_l_t_e_r_c_a_c_h_e__s_e_a_r_c_h__d_e_p_t_h variable is used to minimize the thrashing
  139.      of the cache that would occur if every filter hit was moved to the head
  140.      of the cache. It is defaulted to 4, which permits two simultaneous file
  141.      transfers to occur withour MRU reordering. This value should be tuned
  142.      based on expected system workload.
  143.  
  144.      The _i_p_f_i_l_t_e_r_d__i_n_a_c_t_i_v_e__b_e_h_a_v_i_o_r variable specifies how inbound IP packets
  145.      will be treated when the daemon has died or been killed. A value of 0
  146.      specifies that inbound IP processing should proceed as though filtering
  147.      was not configured. A value of 1 specifies that all inbound IP packets
  148.      (except those from the local host) will be dropped.  Use of this value
  149.      ensures that routing will be disabled in IP firewalls whose daemon is
  150.      inactive, preventing security holes.
  151.  
  152.      With the 5.0 release of IRIX, the _i_p_f_i_l_t_e_r__t_t_l variable is used to set a
  153.      maximum lifetime for idle kernel cache entries.  Entries idle longer than
  154.      that interval (default 60 seconds) are deleted.
  155.  
  156. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  157.      Examples of use of "define" to create macros:
  158.  
  159.      A filter for all possible traffic between two machines, each of which is
  160.      multi-homed:
  161.  
  162.         define ip.betwixt between($1,$3) || between($1,$4) || between($2,$3)
  163.         || between($2,$4)
  164.      (Note: this one-line example is shown on two lines because of formatting
  165.      constraints).
  166.  
  167.      A macro to specify any host not on a given Class C network (or on a Class
  168.      B network with 8-bit subnet masks) as the source. When masking against an
  169.      IP address in a macro, hex must be used. However, the IP (sub)network
  170.      number specified in the filter may be either in hex or dot format.
  171.      Parentheses are used to establish binding and precedence:
  172.  
  173.         define ip.notnetCsrc  not((src & 0xffffff00) = $1)
  174.      Filter examples:
  175.  
  176.      To accept all IP traffic between two single-homed hosts:
  177.  
  178.         accept between speaker squaw
  179.      To reject all IP traffic over one network interface between two hosts:
  180.  
  181.         reject -i ec0 between speaker dizzy
  182.      To reject Sun RPC traffic between two hosts:
  183.  
  184.  
  185.  
  186.  
  187.  
  188.                                                                         PPPPaaaaggggeeee 3333
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))                                                    IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))
  196.  
  197.  
  198.  
  199.         reject between teton 192.99.99.99 and udp.port sunrpc
  200.      To grab all packets from one host over a given network interface rather
  201.      the forwarding them along to their destination:
  202.  
  203.         grab -i ec0 src=boston
  204.      An example of ip.betwixt:
  205.  
  206.         reject ip.betwixt foo1 foo2 boo1 boo2 and tcp.port login
  207.      To reject all FTP connections that do not originate from a given Class B
  208.      net:
  209.  
  210.         reject ip.notnetBsrc 192.26.00.00 and tcp.port ftp
  211. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  212.      netsnoop(1M), master(4)
  213.  
  214. NNNNOOOOTTTTEEEE
  215.      IP filtering may be initiated or disabled only by the superuser. The com-
  216.      mand
  217.  
  218.         /etc/killall ipfilterd
  219.      kills the filtering daemon and zeroes out the kernel cache of filtering
  220.      verdicts. It may also disable all IP forwarding and receipt of any
  221.      inbound IP traffic except that from the local host - see the discussion
  222.      of the _i_p_f_i_l_t_e_r_d__i_n_a_c_t_i_v_e__b_e_h_a_v_i_o_r variable in the FILES section above.
  223.  
  224.      The command
  225.  
  226.         /usr/etc/ipfilterd
  227.      which is normally executed from /_e_t_c/_i_n_i_t._d/_n_e_t_w_o_r_k, starts up the daemon
  228.      and initializes the configured filters.  Only one instance of ipfilterd
  229.      may be active at any time; attempts to start a second daemon will fail
  230.      benignly.
  231.  
  232.      Macros must be defined before they are referenced in filters in
  233.      /_e_t_c/_i_p_f_i_l_t_e_r_d._c_o_n_f.  Each macro definition must be on one line and have
  234.      a maximum of 255 characters.
  235.  
  236.      The daemon's array of filters is generated in the order specified in
  237.      /_e_t_c/_i_p_f_i_l_t_e_r_d._c_o_n_f.  The filtering daemon examines filters from the top
  238.      of the array each time. As soon as it detects a match, it returns the
  239.      associated verdict.  It is possible to have more than one filter match a
  240.      given packet, such as wishing to reject rlogin requests from all of a
  241.      given net except for one particular host. In that case, the particular
  242.      filter should appear first:
  243.  
  244.  
  245.                                                                         PPPPaaaaggggeeee 4444
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252. IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))                                                    IIIIPPPPFFFFIIIILLLLTTTTEEEERRRRDDDD((((1111MMMM))))
  253.  
  254.  
  255.  
  256.         accept ip.src bambi and tcp.port login
  257.      followed by the general case:
  258.  
  259.         reject ip.netBsrc 199.0.2.0 and tcp.port login
  260.      Several macros relating to (sub)networks rather than hosts are predefined
  261.      in /_e_t_c/_i_p_f_i_l_t_e_r_d._c_o_n_f.
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.                                                                         PPPPaaaaggggeeee 5555
  308.  
  309.  
  310.  
  311.